#pragma once

#include "Shapes2D/Point2D.h"
#include "GameLib.h"
#include "Object.h"

class Camera;

class ObjectController
{
private:
    INSTANCE_ID numberOfInstances,nextInstanceId,numberOfCameras;
    Object **list;
    Camera **cameras;
    void resize();
    void resizeCameras();
    bool keyState[256];
    bool mouseState[3];
    Point2D mouse;
	int mapSpecialKey(int key);
	int lowerKey(int key);
public:
    //DO NOT CALL BELOW HERE{
    ObjectController();
    ~ObjectController();
    Object* create(Object *obj);//DO NOT CALL THIS, ONLY "Object" SHOULD WITHIN ITS CONSTRUCTOR
    Object* createCamera(Camera *cam);
    ObjectController& destroy(Object *obj);//DO NOT CALL THIS, ONLY "Object" SHOULD WITHIN _____
    //DO NOT CALL ABOVE HERE}
    
    INSTANCE_ID getNumberOfObjects();
    ObjectController& step();//ONLY CALL FROM MAIN
    ObjectController& draw();//ONLY CALL FROM MAIN
	ObjectController& drawOrtho();//ONLY CALL FROM MAIN
    ObjectController& cameraSetup();//ONLY CALL FROM MAIN
    ObjectController& collisions();//ONLY CALL FROM MAIN
    ObjectController& mouseConst(double x, double y);//ONLY CALL FROM MAIN
    ObjectController& mouseDown(int button, double x, double y);//ONLY CALL FROM MAIN
    ObjectController& mouseUp(int button, double x, double y);//ONLY CALL FROM MAIN
    ObjectController& key(int button);//ONLY CALL FROM MAIN
    ObjectController& keyDown(int button);//ONLY CALL FROM MAIN
    ObjectController& keyUp(int button);//ONLY CALL FROM MAIN
    ObjectController& specialKey(int button);//ONLY CALL FROM MAIN
	ObjectController& specialKeyUp(int button);//ONLY CALL FROM MAIN
	
    bool getKeyState(char key);//ONLY CALLED FROM "Object::getKeyState(char key)"
    bool getMouseState(char key);//ONLY CALLED FROM "Object::getMouseState(char key)"
    Point2D& getMousePosition();//ONLY CALLED FROM "Object::getMousePosition(char key)"
    INSTANCE_ID getNumberOfInstances();//ONLY CALLED FROM "Object::totalObjects()"
    INSTANCE_ID getNumberOfCameras();
};

extern ObjectController objectController;